#include <bits/stdc++.h>
using namespace std;
int a[100001];
int f[100001];
int g[100001];
int main() {
  //    freopen("in.txt", "r", stdin);
  int n = 0;
  int k;
  while (cin >> k) {
    n++;
    a[n] = k;
  }
  f[0] = INT_MAX;
  int len = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] <= f[len]) {
      len++;
      f[len] = a[i];
    } else {
      int *x = upper_bound(f + 1, f + 1 + len, a[i], greater<int>());
      *x = a[i];
    }
  }
  cout << len << endl;

  f[0] = INT_MIN;
  len = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > f[len]) {
      len++;
      f[len] = a[i];
    } else {
      int *x = upper_bound(f + 1, f + 1 + len, a[i]);
      *x = a[i];
    }
  }
  cout << len << endl;

  return 0;
}